Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocreate signing KV #317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Autocreate signing KV #317

wants to merge 1 commit into from

Conversation

alextserepov
Copy link
Contributor

Automatically create signing KV and 2 self-signed certificates inside it.
This should serve as a base for the automatic keyvault creation and also provide signing capabilities for testing.

@alextserepov
Copy link
Contributor Author

This PR is currently under "semi-active" development and is expected to be "ready for review" later this week. I’d prefer to keep it open in the meantime, and I warmly welcome any comments, suggestions, or feedback—your input is greatly appreciated. The reason it has remained in draft status for so long is due to a slight shift in priorities and some challenges with testing.

@alextserepov alextserepov marked this pull request as ready for review December 15, 2024 22:16
@alextserepov alextserepov requested a review from a team December 15, 2024 22:17
Copy link
Collaborator

@cazfi cazfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be three commits like these, first doing one thing and then reverting it. Likely the correct thing to do is to combine them to one commit. In any case they should be reworked.

terraform/jenkins-controller.tf Outdated Show resolved Hide resolved
terraform/jenkins-controller.tf Show resolved Hide resolved
terraform/jenkins-controller.tf Outdated Show resolved Hide resolved
@alextserepov
Copy link
Contributor Author

There should not be three commits like these, first doing one thing and then reverting it. Likely the correct thing to do is to combine them to one commit. In any case they should be reworked.

We can rework or squash. Either way is fine for me.

@henrirosten
Copy link
Collaborator

henrirosten commented Dec 16, 2024

github action checks fail due to terraform formatting issues.
Fix the format by running: terraform fmt -recursive in nix devshell.
Also, you might want to make sure the nix flake check passes locally before pushing.

@alextserepov
Copy link
Contributor Author

github action checks fail due to terraform formatting issues. Fix the format by running: terraform fmt -recursive in nix devshell. Also, you might want to make sure the nix flake check passes locally before pushing.

ACK. Will do. Thank you!

@henrirosten
Copy link
Collaborator

henrirosten commented Dec 16, 2024

Two questions/comments after testing the changes from this PR:

(1) This PR adds the signing keyvault creation, but the added certificates are not used anywhere, right? What's the plan on actually using these certificates later on?

(2) After the changes from this PR, the infra can not be destroyed following the instructions from https://github.com/tiiuae/ghaf-infra/tree/main/terraform#destroying-ghaf-infra-environment or by using the -d option in the terraform-init.sh due to:

╷
│ Error: deleting Certificate "INT-Ghaf-Devenv-Image" (Key Vault "https://ghaf-sig-kv-henri.vault.azure.net/"):
 keyvault.BaseClient#DeleteCertificate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="Forbidden" Message="The user, group or application 
'appid=04b07795-8ddb-461a-bbee-02f9e1bf7b46;oid=f0fc8f23-38a8-41a2-8188-eb037f0df2a0;numgroups=3;iss=https://sts.windows.net/26bb3a23-759b-4cff-91f4-eeec608e777f/' 
does not have certificates delete permission on key vault 'ghaf-sig-kv-henri;location=northeurope'. 
For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125287" InnerError={"code":"ForbiddenByPolicy"}
│ 
│ 
╵
╷
│ Error: deleting Certificate "INT-Ghaf-Devenv-Provenance" (Key Vault "https://ghaf-sig-kv-henri.vault.azure.net/"):
 keyvault.BaseClient#DeleteCertificate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="Forbidden" Message="The user, group or application 
'appid=04b07795-8ddb-461a-bbee-02f9e1bf7b46;oid=f0fc8f23-38a8-41a2-8188-eb037f0df2a0;numgroups=3;iss=https://sts.windows.net/26bb3a23-759b-4cff-91f4-eeec608e777f/' 
does not have certificates delete permission on key vault 'ghaf-sig-kv-henri;location=northeurope'. 
For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125287" InnerError={"code":"ForbiddenByPolicy"}

I believe you want to add Delete (and Purge) permission, the same way we currently do with ssh remote builder keyvault. Also, you may need to disable the purge protection.

@henrirosten
Copy link
Collaborator

There should not be three commits like these, first doing one thing and then reverting it. Likely the correct thing to do is to
combine them to one commit. In any case they should be reworked.

I agree, please squash the commits.

@alextserepov alextserepov requested a review from cazfi December 16, 2024 10:47
@alextserepov
Copy link
Contributor Author

Two questions/comments after testing the changes from this PR:

(1) This PR adds the signing keyvault creation, but the added certificates are not used anywhere, right? What's the plan on actually using these certificates later on?

(2) After the changes from this PR, the infra can not be destroyed following the instructions from https://github.com/tiiuae/ghaf-infra/tree/main/terraform#destroying-ghaf-infra-environment or by using the -d option in the terraform-init.sh due to:

╷
│ Error: deleting Certificate "INT-Ghaf-Devenv-Image" (Key Vault "https://ghaf-sig-kv-henri.vault.azure.net/"):
 keyvault.BaseClient#DeleteCertificate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="Forbidden" Message="The user, group or application 
'appid=04b07795-8ddb-461a-bbee-02f9e1bf7b46;oid=f0fc8f23-38a8-41a2-8188-eb037f0df2a0;numgroups=3;iss=https://sts.windows.net/26bb3a23-759b-4cff-91f4-eeec608e777f/' 
does not have certificates delete permission on key vault 'ghaf-sig-kv-henri;location=northeurope'. 
For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125287" InnerError={"code":"ForbiddenByPolicy"}
│ 
│ 
╵
╷
│ Error: deleting Certificate "INT-Ghaf-Devenv-Provenance" (Key Vault "https://ghaf-sig-kv-henri.vault.azure.net/"):
 keyvault.BaseClient#DeleteCertificate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="Forbidden" Message="The user, group or application 
'appid=04b07795-8ddb-461a-bbee-02f9e1bf7b46;oid=f0fc8f23-38a8-41a2-8188-eb037f0df2a0;numgroups=3;iss=https://sts.windows.net/26bb3a23-759b-4cff-91f4-eeec608e777f/' 
does not have certificates delete permission on key vault 'ghaf-sig-kv-henri;location=northeurope'. 
For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125287" InnerError={"code":"ForbiddenByPolicy"}

I believe you want to add Delete (and Purge) permission, the same way we currently do with ssh remote builder keyvault. Also, you may need to disable the purge protection.

Good point. Will fix & retest. Thanks!

@alextserepov
Copy link
Contributor Author

There should not be three commits like these, first doing one thing and then reverting it. Likely the correct thing to do is to
combine them to one commit. In any case they should be reworked.

I agree, please squash the commits.

Just out of curiosity and "for quality and training purposes", what is the difference between manually squashing them now and squashing them before merge by "Squash and Merge"?

@cazfi
Copy link
Collaborator

cazfi commented Dec 16, 2024

Just out of curiosity and "for quality and training purposes", what is the difference between manually squashing them now and squashing them before merge by "Squash and Merge"?

I've never used "Squash and Merge", but some people claim that it doesn't allow manual editing of the commit message, or at least one easily accidentally go by the commit message automatically combined from the squashed commits. Other than that, I'd prefer to see final commit already before hitting Merge for it.

@alextserepov
Copy link
Contributor Author

Just out of curiosity and "for quality and training purposes", what is the difference between manually squashing them now and squashing them before merge by "Squash and Merge"?

I've never used "Squash and Merge", but some people claim that it doesn't allow manual editing of the commit message, or at least one easily accidentally go by the commit message automatically combined from the squashed commits. Other than that, I'd prefer to see final commit already before hitting Merge for it.

Ok. Sure. I will manually squash it then.

 - create KV
 - Add 2 self-signed certificates

Signed-off-by: Aleksandr Tserepov-Savolainen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants